﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<SLIC.Models.Job.JobDataModel>>" %>
<%@ Import Namespace="MvcContrib.UI.Pager" %>
<%@ Import Namespace="MvcContrib.Pagination" %>
<%@ Import Namespace="log4net" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    View Jobs
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        /// <summary>
        /// 
        ///  <title>SLIC</title>
        ///  <description>View Jobs page for view all jobs</description>
        ///  <copyRight>Copyright (c) 2011</copyRight>
        ///  <company>IronOne Technologies (Pvt)Ltd</company>
        ///  <createdOn>2011-08-05</createdOn>
        ///  <author></author>
        ///  <modification>
        ///     <modifiedBy></modifiedBy>
        ///      <modifiedDate></modifiedDate>
        ///     <description></description>
        ///  </modification>
        ///
        /// </summary>                                                                                 
    %>
    <h2>
        All Jobs
    </h2>        

    <script type='text/javascript'>
    <!--
        function setField() {
            var qString = location.search;
            if (qString.indexOf('searchText') != -1) {
                var data = qString.substring(qString.lastIndexOf('=') + 1, qString.length);
                document.getElementById('searchText').value = data;
            }
        }
        window.onload = setField;
    //-->
    </script>

    <% Html.BeginForm("GetAllJobs", "Job", FormMethod.Get); %>
    <table border="0" cellspacing="0" cellpadding="0" style="color: #000" class="search-table">
        <tr style="border: solid 1px #aaa;">
            <td class="normaltdsForm" style="border-top: solid 1px #aaa;">
                Search:
            </td>
            <td class="normaltdsForm txtErrorSmall" style="border-top: solid 1px #aaa;">
                <input id="searchText" name="searchText" maxlength="120" type="text" style="width:120px; " />
                <input type="submit" value="Search" class="button" alt="Use Job No or Vehicle No for search" />
            </td>
        </tr>
    </table>
     <% Html.EndForm(); %>
        <br/>

    <%   ModelState err = ViewContext.ViewData.ModelState["err"];
         SLIC.Controllers.GenException result = null;

         if (err != null)
         {
             result = (SLIC.Controllers.GenException) err.Errors.ElementAt(0).Exception; %>
    <%:result.Message%>
    <% }
         else
         { %>
    <table id="grid" width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <th scope="col" width="30px" >
                Job No
            </th>
            <th scope="col" width="50px">
                Time Reported
            </th>
            <th scope="col" width="40px">
                Vehicle No
            </th>
            <th scope="col" width="30px">
               Caller Name
            </th>
            <th scope="col" width="30px">
                Contact No
            </th>
            <th scope="col" width="30px">
                Vehicle Description
            </th>
            <th scope="col" width="45px">
                View
            </th>
        </tr>
        <%bool oddEven = true; %>
        <% foreach (var item in Model)
           { %>
        <tr class="<%= (oddEven = !oddEven) ? "even" : "odd" %>">
            <td class="normaltds" width="30px" style="padding-bottom:5px;">
                <%: item.JobNo%>
            </td>
            <td class="normaltds" width="50px" style="text-align:center;" style="padding-bottom:5px;">
                <%: String.Format("{0:dd/MM/yyyy hh:mm tt}", item.TimeReported)%>  <%-- <br />--%>
              <%--   <%: String.Format("{0:hh:mm tt}", item.TimeReported)%>  --%>                   
            </td>
            <td class="normaltds" width="40px" style="padding-bottom:5px;">
                <%: item.VehicleNo%>
            </td>
            <td class="normaltds" width="30px" style="padding-bottom:5px;">
                <%: item.Caller_Name%>
            </td>
            <td class="normaltds" width="30px" style="text-align:right;padding-bottom:5px;">
                <%:  item.Caller_ContactNo%>
            </td>
            <td class="normaltds" width="30px" style="padding-bottom:5px;">
                <%:  item.VehicleDescription%>
            </td>
            <td class="normaltds" width="45px" style="text-align:center;padding-bottom:5px;" >
                <%-- <a href="<%= Url.Action("GetJobByJobNo", new { JobNumber = item.JobNo })%>">
                    <%: item.JobNo%>--%>
                <%--<img src="../../../Content/images/userEdit.png" border="0" alt="Edit Meeting" title="Edit Meeting" />--%></a>
                <a href="<%= Url.Action("GetJobByJobNo",new { JobNumber = item.JobNo })%>">
                    <img src="../../../Content/images/viewInfo.png" border="0" alt="View Details" title="View Details" /></a>
            </td>
        </tr>
        <% } %>
    </table>
    <%} %>
    <br />   
    <div id="pager">
     <%= Html.Pager((IPagination)(Model as IEnumerable<SLIC.Models.Job.JobDataModel>))%>
    </div>
   
</asp:Content>
